// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Recall.generated.h"


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class MISCELLANEOUSPROJECT_API URecall : public UActorComponent
{
	GENERATED_BODY()

public:	
	URecall();

protected:
	virtual void BeginPlay() override;

public:	
	UFUNCTION(BlueprintCallable, Category = TimeAndSpace)
	void ActivateAbility(UMaterialInterface* SourceMaterial, UParticleSystem* Emitter);
private:
	void RecallTimer();
	void SavePlayerTransform();
	void SetPlayerTransform();
	void RecallPositions();
		
private:
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = TimeAndSpace, meta = (AllowPrivateAccess = "true"))
	int32 RecallLength;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = TimeAndSpace, meta = (AllowPrivateAccess = "true"))
	float UpdateFrequency;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = TimeAndSpace, meta = (AllowPrivateAccess = "true"))
	float RecallSpeed;

	class UParticleSystem* Emitter;
	class ACharacter* Character;
	bool IsRecallActive;
	bool CanSetPos;
	TArray<FTransform> PositionArray;
	FTransform LastActorTransform;
	int32 Counter;
	float TimePassage;
	float DeltaTime;
	TArray<class UMaterialInterface* > OriginalMaterials;
	FTimerHandle RecallHandle;
	FTimerHandle UniqueHandle;
};
